package com.tuo51.observation.repositories;

import com.tuo51.observation.domain.ObservatePoint;
//import jdk.internal.dynalink.linker.LinkerServices;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
public interface ObservatePointRepository extends JpaRepository<ObservatePoint, String>, JpaSpecificationExecutor<ObservatePoint> {

    ObservatePoint findTop1ByMonthGreaterThanOrderByMonthAsc(Integer month);

    @Query(value = "select * from ob_point p where p.month <= :month order by p.month desc limit 1", nativeQuery = true)
    ObservatePoint findTop1ByMonthLessThanOrderByMonthDesc(@Param("month") Integer month);


    List<ObservatePoint> findByMonthOrderByIndexOnPaper(Integer month);

    List<ObservatePoint> findAllByIdIn(List<String> ids);

}
